package xyz.coolcsm.security.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSenderImpl;
/**
 * @author 什锦
 * @since 2021-06-1
 */
public class MailUtils {


    @Autowired
    static JavaMailSenderImpl mailSender;

    public static void setMailSender(JavaMailSenderImpl mailSender) {
        MailUtils.mailSender = mailSender;
    }

    public static boolean sendMail(String to, String text, String title){

            SimpleMailMessage message = new SimpleMailMessage();
            message.setSubject(title);
            message.setText(text);
            message.setTo(to);
            message.setFrom("******@qq.com");
            mailSender.send(message);
        return true;
    }
}
